#!/bin/bash

while true; do
    echo "请选择操作："
    echo "1. 磁盘分区"
    echo "2. CPU负载"
    echo "3. 剩余内存"
    echo "4. 退出"
    read -p "输入数字选择操作：" option

    case $option in
        1)
            echo "主机名："
            hostname
            echo "系统版本："
            uname -r
            echo "----------分区情况----------"
            df -h | grep -vE '^Filesystem|tmpfs|cdrom'
            ;;
        2)
            echo "1 分钟平均负载："
            uptime | awk '{print $10}'
            echo "5 分钟平均负载："
            uptime | awk '{print $11}'
            echo "15 分钟平均负载："
            uptime | awk '{print $12}'
            ;;
        3)
            echo "目前可用内存："
            free -h | awk '/Mem:/ {print $4}'
            echo "可用 Swap 分区："
            free -h | awk '/Swap:/ {print $4}'
            ;;
        4)
            clear
            echo "bye~"
            exit 0
            ;;
        *)
            echo "无效的选项，请重新输入！"
            ;;
    esac
    echo "" # 打印一个空行
done